package top.tagao.service_sms.receiver;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.tagao.service_sms.service.SmsService;
import top.tagao.yygh.common.rabbit.constant.MqConst;
import top.tagao.yygh.vo.msm.MsmVo;

/**
 * @author fu-xiao-liu
 * @Date 2022/3/14 19:22
 */
@Component
public class SmsReceiver {
    @Autowired
    private SmsService smsService;


    @RabbitListener(bindings = @QueueBinding
            (value = @Queue(value = MqConst.QUEUE_MSM_ITEM, durable = "true"),
                    exchange = @Exchange(value = MqConst.EXCHANGE_DIRECT_MSM),
                    key = {MqConst.ROUTING_MSM_ITEM}
            )
    )
    public void send(MsmVo msmVo, Message message, Channel channel){
        smsService.send(msmVo);
    }
}


